<html>
<head><meta charset="utf-8"><title>Is MIR in SSA form? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html">Is MIR in SSA form?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="207431397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207431397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nick Fitzgerald <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207431397">(Aug 19 2020 at 16:39)</a>:</h4>
<p><a href="https://rustc-dev-guide.rust-lang.org/mir/index.html">https://rustc-dev-guide.rust-lang.org/mir/index.html</a> doesn't mention SSA, so I'm assuming MIR is <em>not</em> in SSA form? Is this correct?</p>
<p>But based on the MIR emitted for <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=b66d7f7b2493367afc950c489a12dfcc">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=b66d7f7b2493367afc950c489a12dfcc</a> it seems like it is "SSA-ish" where there are explicit moves instead of phis.</p>
<p>Where can I learn more about this aspect of MIR, and what its guarantees around assignments are?</p>
<p>Thanks!</p>



<a name="207432008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207432008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207432008">(Aug 19 2020 at 16:45)</a>:</h4>
<p>the guide is not normative, so it probably just hasn't been updated</p>



<a name="207432132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207432132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207432132">(Aug 19 2020 at 16:46)</a>:</h4>
<p>but I'm not sure where to learn more</p>



<a name="207436079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207436079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207436079">(Aug 19 2020 at 17:18)</a>:</h4>
<p>MIR is not in SSA form, that's correct. A trivial example: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=1d4897a3904a537bf8590facc76ea387">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=1d4897a3904a537bf8590facc76ea387</a></p>
<div class="codehilite"><pre><span></span><code><span class="n">_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="mi">1</span><span class="k">i32</span><span class="p">;</span><span class="w"></span>
<span class="n">_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="mi">2</span><span class="k">i32</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="207436147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207436147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207436147">(Aug 19 2020 at 17:19)</a>:</h4>
<p>Sometimes that kind of info is contained in the original MIR RFC but I didn't see anything more than just "MIR is not SSA".</p>



<a name="207436166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207436166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207436166">(Aug 19 2020 at 17:19)</a>:</h4>
<p>What sort of information are you looking for <span class="user-mention" data-user-id="220917">@Nick Fitzgerald</span> ?</p>



<a name="207438610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207438610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nick Fitzgerald <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207438610">(Aug 19 2020 at 17:39)</a>:</h4>
<p>Is there anything that tracks which places have multiple defs or anything like that? I'm wondering what it would take to determine whether two uses of "_1" refer to the same value or not</p>



<a name="207439214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207439214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207439214">(Aug 19 2020 at 17:45)</a>:</h4>
<p>That sounds like a data-flow analysis</p>



<a name="207439261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207439261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207439261">(Aug 19 2020 at 17:45)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="118594">@ecstatic-morse</span></p>



<a name="207439380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207439380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207439380">(Aug 19 2020 at 17:46)</a>:</h4>
<p>We don't have a reaching definitions analysis in the compiler currently, although I implemented one on top of an earlier version of the dataflow framework that didn't get merged.</p>



<a name="207439406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207439406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207439406">(Aug 19 2020 at 17:46)</a>:</h4>
<p>It wouldn't be too hard to revive that PR</p>



<a name="207439625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207439625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207439625">(Aug 19 2020 at 17:48)</a>:</h4>
<p>The codegen backend has an analysis that detects SSA-like MIR locals</p>



<a name="207452681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Is%20MIR%20in%20SSA%20form%3F/near/207452681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Is.20MIR.20in.20SSA.20form.3F.html#207452681">(Aug 19 2020 at 19:40)</a>:</h4>
<p><span class="user-mention" data-user-id="220917">@Nick Fitzgerald</span> lemme know if you have any specific questions</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>